<script setup>
import { useOrderStore, useShopInfoStore } from '@/stores'
import { computed, reactive, ref } from 'vue'

const useOrderList = useOrderStore()
const ShopList = useShopInfoStore()
const list = useOrderList.orderList

console.log(list)
console.log(ShopList.nearbyList)

const getNameById = (id) => {
  return ShopList.nearbyList.find((item) => item.id == id)?.name || '未知'
}
</script>
<template>
  <div class="order-main">
    <div class="header">我的订单</div>
    <div class="main">
      <div class="main-order" v-for="item in list" :key="item">
        <!-- 组件 -->
        <div class="main-order-top">
          <div class="main-order-top-left">{{ getNameById(item.shopId) }}</div>
          <div class="main-order-top-right">已下单</div>
        </div>
        <div class="main-order-bottom">
          <div class="main-order-bottom-left">
            <img
              v-for="(img, index) in item.productImgList"
              :key="index"
              :src="`http://www.dell-lee.com/imgs/vue3/${img}.png`"
              alt=""
            />
          </div>
          <div class="main-order-bottom-right">
            <div class="totalPrice">￥{{ item.totalPrice }}</div>
            <div class="totalCount">共{{ item.totalCount }}件</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<style scoped lang='scss'>
@import '@/style/viriables.scss';

@mixin flexStyle() {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50%;
}

.order-main {
  width: 100%;
  height: 100vh;
  background-color: #dfdfdf52;
}

.header {
  $height: 5vh;
  text-align: center;
  height: $height;
  line-height: $height;
  font-size: 23px;
  margin-bottom: 10px;
  background-color: $bgColor;
}

.main {
  width: 90%;
  height: 95vh;
  margin: 0 auto;
  padding:10px;
  overflow: auto;
  & > div {
    width: 100%;
    justify-content: space-between;
    background-color: #fff;
  }
  &-order-top {
    padding-left: 10px;
    @include flexStyle();
    &-left {
      font-size: 20px;
      font-weight: bold;
    }
    &-right {
      font-size: 15px;
      padding-right: 10px;
      color: #c2c2c2;
    }
  }
  &-order-bottom {
    @include flexStyle();
    &-left {
      display: flex;
      padding-left: 10px;
      width: 50%;
      height: 90%;
      flex-wrap: wrap;
      align-content: flex-start;
      img {
        width: 20%;
        aspect-ratio: 1/1;
      }
    }
    &-right {
      text-align: right;
      .totalPrice {
        color: red;
      }
    }
  }
}

.main-order {
  width: 90%;
  height: 100px;
  margin: 0 auto;
  padding: 10px;
}
</style>